import React, { Component } from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import { Layout } from "antd";
import memoryUtils from "../../utils/memoryUtils";
import LeftNav from "../../components/left-nav";
import Header from "../../components/header";
import Home from "../home/home";
import NotFound from "../not-found/not-found";
import strategic from "../defense/strategic/strategic";
import thereportcenter from "../defense/thereportcenter/thereportcenter";
import condition from "../flowAnalysis/condition/condition";
import warning from "../flowAnalysis/warning/warning";
import retrieve from "../flowAnalysis/retrieve/retrieve";
import assetsmanagement from "../assetsManagement/assetsmanagement";
import task from "../defense/task/task";
import security from "../security/security";
import project from "../calculation/project/project";
import service from "../calculation/service/service";
import overview from "../IllegalOutreach/overview/overview";
import EquipmentAccess from "../IllegalOutreach/EquipmentAccess/EquipmentAccess";
import OutreachAnalysis from "../IllegalOutreach/OutreachAnalysis/OutreachAnalysis";
import analysisOverview from "../domainNameResolution/analysisOverview/analysisOverview";
import AnalysisOfMaliciousDomainNameAccess from "../domainNameResolution/AnalysisOfMaliciousDomainNameAccess/AnalysisOfMaliciousDomainNameAccess";
import analysisOfUserBehaviors from "../domainNameResolution/analysisOfUserBehaviors/analysisOfUserBehaviors";
import HighRiskHostAnalysis from "../domainNameResolution/HighRiskHostAnalysis/HighRiskHostAnalysis";
import intelligentLearning from "../domainNameResolution/intelligentLearning/intelligentLearning";
import management from "../domainNameResolution/management/management";
const { Footer, Sider, Content } = Layout;
/*
后台管理的路由组件
 */
export default class Admin extends Component {
  render() {
    const user = memoryUtils.user;
    // 如果内存没有存储user ==> 当前没有登陆
    if (!user || !user._id) {
      // 自动跳转到登陆(在render()中)
      return <Redirect to="/login" />;
    }
    return (
      <Layout style={{ minHeight: "100vh", overflow: "auto" }}>
        <Sider>
          <LeftNav />
        </Sider>
        <Layout>
          <Header>Header</Header>
          <Content style={{ margin: 20, backgroundColor: "#fff" }}>
            <Switch>
              <Redirect from="/" exact to="/home" />
              <Route path="/home" component={Home} />
              <Route path="/assetsmanagement" component={assetsmanagement} />
              <Route path="/strategic" component={strategic} />
              <Route path="/task" component={task} />
              <Route path="/thereportcenter" component={thereportcenter} />
              <Route path="/OutreachAnalysis" component={OutreachAnalysis} />
              <Route path="/security" component={security} />
              <Route path="/condition" component={condition} />
              <Route path="/warning" component={warning} />
              <Route path="/retrieve" component={retrieve} />
              <Route path="/project" component={project} />
              <Route path="/service" component={service} />
              <Route path="/overview" component={overview} />
              <Route path="/EquipmentAccess" component={EquipmentAccess} />
              <Route
                path="/AnalysisOfMaliciousDomainNameAccess"
                component={AnalysisOfMaliciousDomainNameAccess}
              />
              <Route
                path="/analysisOfUserBehaviors"
                component={analysisOfUserBehaviors}
              />
              <Route
                path="/HighRiskHostAnalysis"
                component={HighRiskHostAnalysis}
              />
              <Route
                path="/intelligentLearning"
                component={intelligentLearning}
              />
              <Route path="/analysisOverview" component={analysisOverview} />
              <Route path="/management" component={management} />
              <Route component={NotFound} />
            </Switch>
          </Content>
          <Footer style={{ textAlign: "center", color: "#cccccc" }}></Footer>
        </Layout>
      </Layout>
    );
  }
}
